<?php
namespace app\common\services;

/**
 * Class BaseService 基础服务,记录一些错误信息
 * Author: yanhaoqiang
 * @package app\common\services
 */
class BaseService {
    protected static $_error_msg = null;
    protected static $_error_code = null;

    /**
     * [_err ]
     * @param string $msg
     * @param int $code
     * @return bool
     */
    public static function _err($msg = '', $code = -1) {
        if ($msg) {
            self::$_error_msg = $msg;
        } else {
            self::$_error_msg = '操作失败';
        }
        self::$_error_code = $code;
        return false;
    }

    /**
     * [getLastErrorMsg ]
     * @return null|string
     */
    public static function getLastErrorMsg() {
        return self::$_error_msg ? self::$_error_msg : "";
    }

    /**
     * [getLastErrorCode ]
     * @return int|null
     */
    public static function getLastErrorCode() {
        return self::$_error_code ? self::$_error_code : 0;
    }
}